package cn.buk.tms.hotel.dao;

import cn.buk.tms.dao.BaseAbstractDao;
import cn.buk.tms.entity.order.hotel.HotelOrder;
import cn.buk.tms.entity.order.hotel.HotelOrderPrice;
import cn.buk.tms.entity.misc.OperationLog;
import cn.buk.tms.hotel.sc.HotelOrderSearchCriteria;

import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * 酒店订单保存接口
 */
public interface HotelOrderDao extends BaseAbstractDao {

    /**
     * 保存酒店订单
     */
    int createHotelOrder(HotelOrder o);

    HotelOrder getHotelOrderById(int id);

    /**
     * 查找酒店订单
     * @param enterpriseId 企业id
     * @param sc 查询条件
     */
    List<HotelOrder> searchHotelOrders(int enterpriseId, HotelOrderSearchCriteria sc, List<Integer> allowedCustomerIds);

    /**
     * 修改酒店订单的备注
     */
    int updateHotelOrderRemark(int enterpriseId, String username, int orderId, String remark);

    /**
     * 修改酒店订单的供应商
     */
    int updateHotelOrderSupplier(int enterpriseId, String username, int orderId, int supplierId);

    /**
     * 修改订单价格
     */
    int updateHotelOrderPrice(int enterpriseId, String username, int orderId, double price, double cost, double serviceCharge, double totalAmount, double totalCost, double profit);

    /**
     * 修改酒店订单的支付方式
     */
    int updateHotelOrderPaymentMethod(int enterpriseId, String username, int orderId, int paymentMethodId);

    int submitHotelOrder(int enterpriseId, String username, int orderId);

    int approveHotelOrder(int enterpriseId, String username, int orderId, int denyCode, String denyReason);

    int processHotelOrder(int enterpriseId, String username, int orderId);

    int finishHotelOrder(int enterpriseId, String username, int orderId, String confirmNo);

  /**
   * 为酒店订单增加操作记录
   */
    void appendHotelOrderHistory(int enterpriseId, String username, int orderId, String remark);

    List<OperationLog> searchHotelOrderHistory(int enterpriseId, int orderId);

    /**
     * 取消酒店订单
     */
    int cancelHotelOrder(int enterpriseId, String username, int hotelOrderId, String remark);

    int rollbackHotelOrder(int enterpriseId, String username, int orderId, final String remark);

    /**
     * 修改酒店订单的订单状态
     * @param supplierOrderId 供应商订单号
     * @param supplierOrderStatus 供应商订单状态
     * @param orderConfirmType 订单确认方式
     * @param orderConfirmNo 订单确认号
     * @param orderRejectType 订单拒绝类型
     * @param orderRejectReason orderRejectReason
     * @param supplierRemark 备注
     */
  int updateHotelOrderSupplierOrderStatus(int enterpriseId, String username,
                                          int orderId,
                                          String supplierOrderId,
                                          int supplierOrderStatus,
                                          int orderConfirmType,
                                          String orderConfirmNo,
                                          int orderRejectType,
                                          String orderRejectReason,
                                          String supplierRemark);


  List<HotelOrder> searchNeedAssignApproverHotelOrders(int enterpriseId);

    int updateHotelOrderApprover(int enterpriseId, String username, int orderId, String approver);

    /**
     * 查找需要验价的酒店订单
     */
  List<HotelOrder> searchNeedPriceCheckHotelOrders(int enterpriseId, Date startDate);

  /**
   * /**
   *    * 保存订单的价格校验结果
   * @param checkStatus null - 表示不更改priceChecked字段
   */
  void updateHotelOrderPriceChecked(int enterpriseId, int id, String agentName, Integer checkStatus, String remark);

  /**
   * 用新的每日价格（代理商含税底价）更新订单价格
   */
  void updateHotelOrderPrice(int enterpriseId, String agentName, int orderId, Set<HotelOrderPrice> newPrices);

  /**
   * 查找需要合规性检查的酒店订单
   */
  List<HotelOrder> searchMeetPolicyHotelOrders(int enterpriseId);

  void updateHotelOrderViolationStatus(int enterpriseId, String username, int orderId, int status, String remark);

  List<HotelOrder> checkHotelOrderCityIdIsNull(int enterpriseId);

  void updateHotelOrderCityInfo(int enterpriseId, String username, int orderId, int cityId, String cityName);

  int updateHotelOrderChannel(int enterpriseId, String username, int orderId, int channel);

  List<HotelOrder> searchHotelOrderByStatus(int enterpriseId, int status, int max);

  void updateHotelOrderHotelAddress(int enterpriseId, String username, int orderId, String address);

  void updateHotelOrderNotifyStatus(int enterpriseId, String username, int orderId, String content);

  /**
   * 查找未销账的酒店订单
   * @param max 最大返回记录数
   */
  List<HotelOrder> searchUnpaidOrders(int max);

  /**
   *
   */
  int setOrderWriteOff(int enterpriseId, String agentName, int orderId, String remark);
}
